#http://music.163.com/song/media/outer/url?id={ID}.mp3 歌曲真实下载地址
#https://music.163.com/weapi/cdns?csrf_token= 歌手

import requests
from lxml import etree
url = 'https://music.163.com/#/discover/toplist'
url_base = 'https://music.163.com/song/media/outer/url?id='
resp = requests.get(url)

html = etree.HTML(resp.text)

url_list = html.xpath('/html/body/div[3]/div[2]/div/div[2]/div[2]/div/div[1]/table/tbody/tr[3]')

print(url_list)

# for data in url_list:
#     href = data.xpath('./@href/')[0]

    # music_id = href.split("=")[1]
    # music_name = data.xpath("./title")[0]
    # music_url = url_base + music_id
    # music = requests.get(url=music_url)
    # with open(f'D:/python_music/{music_name}.mp3', 'wb') as f:
    #     f.write(music.content)
    #     print('%s 下载完毕' % music_name)
